<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <?php
    session_start();
    
    if (!isset($_SESSION['userid']))
    {
        echo"User not logged in";
        echo"</html>";
        exit();
    }
    
    if (isset($_POST['logout']))
    {
        include 'ClassLibs/statics.php';
        vLogout();
        header("Location: index.php");
    }
    
    if (isset($_POST['search']) && !isset($_POST['search_choice']))
    {
        echo "<script>alert('Please choose a search method')</script>";
    }
    
    else if (isset($_POST['search']) && $_POST['search_choice'] === 'author')
    {
        header("Location: Search_Author.php");
    }
    
    else if (isset($_POST['search']) && $_POST['search_choice'] === 'date')
    {
        header("Location: Search_Date.php");
    }

    if (isset($_POST['newpost']))
    {
        header("Location: NewPost.php");
    }
    echo"<h1>welcome " . $_SESSION['userid'] . "</h1>";
    ?>
    <head>
        <link rel="stylesheet" type="text/css" href="index_style.css"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title><?php echo"Welcome user:" . $_SESSION['userid']; ?></title>
    </head>
    <body>
        <form method="POST">
            <input type="submit" name="logout" value="Log out"/>
        </form>
        <form method="POST">
            <table>
                <tr>
                    <td><input type="submit" name="search" value="Search"/></td>
                    <td><input type="radio" name="search_choice" value="author" id="author"/><label for="author">By author</label></td>
                    <td><input type="radio" name="search_choice" value="date" id="date"/><label for="date">By date</label></td>
                </tr>
                <tr>
                    <td><input type="submit" name="newpost" value="New post"/></td>
                </tr>
            </table>
        </form>
    </body>
</html>
